$('#tel')
    .blur(function () {
        const tel = $(this).val()
        console.log(tel);
        if (tel.length == 0) return
        if (/^(?:(?:\+|00)86)?1[3-9]\d{9}$/.test(tel) == false) {
            $('#yz').show()
        }
    })
    .focus(function () {
        $('#yz').hide()
    })
$('#btn').click(function () {
    const cname = $('#cname').val()
    const car_num = $('#car_num').val()
    const car_vin = $('#car_vin').val()
    const tel = $('#tel').val()
    const address = $('#address').val()
    if ((cname && car_num && car_vin && tel && address)) {
        var params = { cname, car_num, car_vin, tel, address }
        var url = 'http://127.0.0.1:3000/customer/add'
        $.post(url, params, data => {
            if (data.code == 200) {
                alert('新增客户信息成功!');
                window.location = '#p=customer'
            } else {
                alert('添加客户信息失败')
            }
        })
    } else {
        alert('请输入完整的客户信息')
    }
})

